import Main from "./main.vue";
import { IContextMenuItem } from "./IContextMenuItem";
import Vue from "vue";

interface ISidebarIframeOptions {
  menuItems: IContextMenuItem[];
  left: number;
  top: number;
}

const JuContextMenu = (options: ISidebarIframeOptions) => {
  const instance: any = new Main();
  instance.left = options.left;
  instance.top = options.top;
  instance.menuItems = options.menuItems;
  // popup 中的属性
  // instance.lockScroll = true; // 锁定滚动条
  // instance.modal = true;// 模态框，有遮罩
  // instance.modalAppendToBody = true;// 模态框插入到body 中
  instance.$mount();

  document.body.appendChild(instance.$el);

  Vue.nextTick(() => {
    instance.visible = true;
  });

  return instance;
};

JuContextMenu.show = (options: ISidebarIframeOptions) => JuContextMenu(options);

export default JuContextMenu;
